package com.neuedu.shixun.hospital2.service.Impl;
import org.springframework.data.domain.Page;
import com.neuedu.shixun.hospital2.entity.User;
import com.neuedu.shixun.hospital2.repository.UserRepository;
import com.neuedu.shixun.hospital2.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserRepository userRepository;
    @Override
    public List<User> getUser() {
      List<User> list=userRepository.findAll();
      return list;
    }
    @Override
    public User saveUser(User user) {
        return userRepository.save(user);
    }
    @Override
    public Page<User> findByPage(int pageCode, int pageSize) {
        Pageable pageable = new PageRequest(pageCode, pageSize);
        return userRepository.findAll(pageable);
    }
}
